<?php
/**
 * 支付模块控制器
 */
namespace Admin\Controller;
class PaymentController extends AdminBaseController {
	public function index(){
		
	}
	//支付方式列表
	public function methods(){
		$model = M('payment');
        $where = array();
		$where['status'] =array('egt',0);
        $order = " id DESC";
        $limit = 5;
        $count = $model->where($where)->count();
        $Page = new \Think\Page($count,$limit);
        //设置分页显示
        $Page->setConfig('prev','Prev');
        $Page->setConfig('next','Next');
        // 分页显示输出
        $show = $Page->show();
        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = $model->where($where)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();
        $result = array(
            'list' => $list,
            'page' => $show
        );
        $this->assign('data',$result);
        $this->display();
	}
	//添加编辑支付二维码
	public function add_qrcode(){
		$id = I('get.id',0,'intval');
        $PaymentModel = new \Common\Model\PaymentModel();
        if (IS_AJAX) {
            if (!$PaymentModel->send_addData()) {
                //操作失败
                exit(json_encode(array('status'=>0,'msg'=>$PaymentModel->getError())));
            } else {
                //操作成功
                exit(json_encode(array('status'=>1,'msg'=>'操作成功.^_^','url'=>U('Payment/methods'))));
            }
        } else {
            if ($id) {
                //编辑模式
                $this->assign('data',$PaymentModel->getFindData($id));
                $this->display('edit_qrcode');
            } else {
                //添加模式
                $this->display();
            }
        }
	}
	//删除支付二维码
	public function del_qrcode(){
		
	}
}